package com.example.simpleforum.model;

import java.sql.Timestamp;

/**
 * 帖子实体类
 */
public class Post {
    private int id;             // 帖子ID，主键
    private String title;       // 帖子标题
    private String content;     // 帖子内容
    private int userId;         // 发布用户ID，外键
    private int forumId;        // 所属板块ID，外键
    private Timestamp createTime; // 发布时间
    private Timestamp updateTime; // 更新时间
    
    // 非数据库字段，用于展示
    private String username;    // 发布用户名
    private String forumName;   // 板块名称

    // 构造函数
    public Post() {
    }

    public Post(String title, String content, int userId) {
        this.title = title;
        this.content = content;
        this.userId = userId;
        this.forumId = forumId;
        this.createTime = new Timestamp(System.currentTimeMillis());
        this.updateTime = this.createTime;
    }

    public Post(int id, String title, String content, int userId, int forumId, Timestamp createTime, Timestamp updateTime) {
        this.id = id;
        this.title = title;
        this.content = content;
        this.userId = userId;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    // Getter和Setter方法
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }
    
    public String getUsername() {
        return username;
    }
    
    public void setUsername(String username) {
        this.username = username;
    }
    
    public int getForumId() {
        return forumId;
    }
    
    public void setForumId(int forumId) {
        this.forumId = forumId;
    }
    
    public String getForumName() {
        return forumName;
    }
    
    public void setForumName(String forumName) {
        this.forumName = forumName;
    }

    @Override
    public String toString() {
        return "Post{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", content='" + content + '\'' +
                ", userId=" + userId +
                ", forumId=" + forumId +
                ", username='" + username + '\'' +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
}